//
// Created by luolijun on 2021/10/31.
//

#include "FacadePainterImpl.h"

namespace falcon {

FacadePainterImpl::FacadePainterImpl() {
}

void FacadePainterImpl::attach(QPainter* p, const QStyleOptionGraphicsItem* o, QWidget* w) {
    painter = (QPainter*)p;
    option = (const QStyleOptionGraphicsItem*)o;
    widget = (QWidget*)w;
}

void FacadePainterImpl::detach() {
}

void FacadePainterImpl::drawText(const falcon::RECT& rect, uint32_t style, const char* text) {
    painter->drawText(QRectF(rect.aleft, rect.atop, rect.awidth, rect.aheight), style, QString(text));
}

void FacadePainterImpl::drawRect(const falcon::RECT& rect) {
    painter->drawRect(QRectF(rect.aleft, rect.atop, rect.awidth, rect.aheight));
}

void FacadePainterImpl::drawLine(const falcon::LINE& line) {
    painter->drawLine(QLineF(line.start.x, line.start.y, line.end.x, line.end.y));
}

} // namespace qt
